home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1993…ch: Other People's Memory / ADC Developer CD (1993-03) (''Other People's Memory'')_iso / Dev.CD Mar 93.iso / Technical Documentation / Sample Code / DTS.Lib & Samples / DTS.Draw / DoEvent.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-10-22  |  3.4 KB  |  167 lines  |  [TEXT/MPS ]

  1. /*
  2. ** Apple Macintosh Developer Technical Support
  3. **
  4. ** File:        DoEvent.c
  5. ** Written by:    Eric Soldan
  6. **
  7. ** Copyright © 1990-1992 Apple Computer, Inc.
  8. ** All rights reserved.
  9. */
  10.  
  11.  
  12.  
  13. /*****************************************************************************/
  14.  
  15.  
  16.  
  17. #include "App.h"            /* Get the application includes/typedefs, etc.    */
  18. #include "App.Common.h"        /* Get the stuff in common with rez.            */
  19. #include "App.protos.h"        /* Get the prototypes for the application.        */
  20.  
  21. #ifndef __DESK__
  22. #include <Desk.h>
  23. #endif
  24.  
  25. #ifndef __DISKINIT__
  26. #include <DiskInit.h>
  27. #endif
  28.  
  29. #ifndef __ERRORS__
  30. #include <Errors.h>
  31. #endif
  32.  
  33. #ifndef __MENUS__
  34. #include <Menus.h>
  35. #endif
  36.  
  37. #ifndef __TOOLUTILS__
  38. #include <ToolUtils.h>
  39. #endif
  40.  
  41. #ifndef __UTILITIES__
  42. #include "Utilities.h"
  43. #endif
  44.  
  45.  
  46.  
  47. /*****************************************************************************/
  48.  
  49.  
  50.  
  51. extern CursPtr    gCursorPtr;
  52.     /* See the file Window2.c for comments about this global. */
  53.  
  54.  
  55.  
  56. /*****************************************************************************/
  57. /*****************************************************************************/
  58.  
  59.  
  60.  
  61. /* Do the right thing for an event.  Determine what kind of event it is, and
  62. ** call the appropriate routines. */
  63.  
  64. #pragma segment Main
  65. void    DoEvent(EventRecord *event)
  66. {
  67.     Point        pt;
  68.     OSErr        err;
  69.     TEHandle    teHndl;
  70.  
  71.     switch(event->what) {
  72.  
  73.         case nullEvent:
  74.             DoIdleTasks(event);
  75.             break;
  76.  
  77.         case mouseDown:
  78.             DoMouseDown(event);
  79.             break;
  80.  
  81.         case autoKey:
  82.         case keyDown:
  83.             DoKeyDown(event);
  84.             break;
  85.  
  86.         case activateEvt:
  87.             gCursorPtr = nil;            /* Force recalculation of the cursor. */
  88.             DoActivate((WindowPtr)event->message);
  89.             break;
  90.  
  91.         case updateEvt:
  92.             DoUpdate((WindowPtr)event->message);
  93.             break;
  94.  
  95.         case kHighLevelEvent:
  96.             gCursorPtr = nil;            /* Force recalculation of the cursor. */
  97.             DoHighLevelEvent(event);
  98.             break;
  99.  
  100.         case osEvt:
  101.             gCursorPtr = nil;            /* Force recalculation of the cursor. */
  102.             switch ((event->message >> 24) & 0xFF) {
  103.                     /* Must logical and with 0xFF to get only low byte. */
  104.                     /* High byte of message. */
  105.  
  106.                 case mouseMovedMessage:
  107.                     break;
  108.  
  109.                 case suspendResumeMessage:
  110.                         /* Suspend/resume is also an activate/deactivate. */
  111.                     gInBackground = !((event->message) & resumeFlag);
  112. #if VH_VERSION
  113.                     CTEConvertClipboard((event->message) & convertClipboardFlag, !gInBackground);
  114. #endif
  115.                     DoActivate(FrontWindow());
  116.                     HiliteWindows();
  117.                     break;
  118.             }
  119.             break;
  120.  
  121.         case diskEvt:
  122.             gCursorPtr = nil;            /* Force recalculation of the cursor. */
  123.             if (HiWord(event->message) != noErr) {
  124.                 SetPt(&pt, kDILeft, kDITop);
  125.                 err = DIBadMount(pt, event->message);
  126.             }
  127.             break;        /* It is not a bad idea to at least call DIBadMount
  128.                         ** in response to a diskEvt, so that the user can
  129.                         ** format a floppy. */
  130.     }
  131.  
  132.     DoCursor();
  133.     DoAdjustMenus();
  134.  
  135.     if (teHndl = CTEFindActive(nil)) {
  136.         BeginContent((*teHndl)->inPort);
  137.         CTEIdle();
  138.         EndContent((*teHndl)->inPort);
  139.     }
  140. }
  141.  
  142.  
  143.  
  144. /*****************************************************************************/
  145.  
  146.  
  147.  
  148. /* This is called when a window is activated or deactivated. */
  149.  
  150. #pragma segment Main
  151. void    DoActivate(WindowPtr window)
  152. {
  153.     NotifyCancel();
  154.  
  155.     if (!IsDAWindow(window)) {
  156.         SetPort(window);
  157.         DoCtlActivate(window);
  158.         DoDrawFrame(window);            /* Redraw window scrollbars and growIcon, if any. */
  159.         BeginContent(window);
  160.         DoDrawControls(window, true);    /* Redraw content scrollbars. */
  161.         EndContent(window);
  162.     }
  163. }
  164.  
  165.  
  166.  
  167.